#include "Generation/Piecemeal/Direction.h"
#include "System/GameConfiguration.h"

TOWERDEFENCE_API const FDirection FDirection::none(0,0);
TOWERDEFENCE_API const FDirection FDirection::n(0, -1);
TOWERDEFENCE_API const FDirection FDirection::ne(1, -1);
TOWERDEFENCE_API const FDirection FDirection::e(1, 0);
TOWERDEFENCE_API const FDirection FDirection::se(1, 1);
TOWERDEFENCE_API const FDirection FDirection::s(0, 1);
TOWERDEFENCE_API const FDirection FDirection::sw(-1, 1);
TOWERDEFENCE_API const FDirection FDirection::w(-1, 0);
TOWERDEFENCE_API const FDirection FDirection::nw(-1, -1);

TOWERDEFENCE_API const TArray<FDirection>  FDirection::all
{
	n, ne, e, se, s, sw, w, nw
};

TOWERDEFENCE_API const TArray<FDirection>  FDirection::cardinal
{
	n, e, s, w
};

TOWERDEFENCE_API const TArray<FDirection>  FDirection::intercardinal
{
	ne, se, sw, nw
};

FORCEINLINE FDirection::FDirection(int x, int y)
{
	this->x = x;
	this->y = y;
}

FORCEINLINE bool FDirection::operator==(const FDirection& other) const
{
	if (this->x == other.x && this->y == other.y)
	{
		return true;
	}
	return false;
}

FORCEINLINE bool FDirection::operator!=(const FDirection& other) const
{
	return !(this == &other);
}

FDirection FDirection::rotate180()
{
	if (*this == none)
	{
		return none;
	}
	else if (*this == n)
	{
		return s;
	}
	else if (*this == ne)
	{
		return sw;
	}
	else if (*this == e)
	{
		return w;
	}
	else if (*this == se)
	{
		return nw;
	}
	else if (*this == s)
	{
		return n;
	}
	else if (*this == sw)
	{
		return ne;
	}
	else if (*this == w)
	{
		return e;
	}
	else if (*this == nw)
	{
		return se;
	}
	else
	{
		UE_LOG(LogTD, Error, TEXT("unreachable"));
		return none;
	}
}



